﻿Imports System.Windows.Forms

Public Class frmFPS

    Public Shadows Function ShowDialog(ByVal owner As Windows.Forms.IWin32Window, ByVal prevFPS As Single) As DialogResult
        txtFPS.Text = prevFPS
        MyBase.ShowDialog(owner)
    End Function

    Public ReadOnly Property FPS() As Single
        Get
            Return Single.Parse(txtFPS.Text)
        End Get
    End Property

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Dim val As Single
        If Not Single.TryParse(txtFPS.Text, val) OrElse val <= 0.0 Then
            MessageBox.Show("Il numero inserito non è corretto! Inserire un numero decimale, intero o frazionario, positivo.", "Errore formato FPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtFPS.Focus()
            txtFPS.SelectAll()
            Exit Sub
        End If

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnnulla.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

End Class
